<?php
	include_once('../../../parametros.php');	
	session_start();		
	if (!empty($_SESSION['correo'])){
		$session=true;				
		$nomUsuario=$_SESSION['nomUsu'];		
		$usuRol=$_SESSION['usuRol'];								
		$ultAcceso=$_SESSION['ultAcc'];
		$usuEstado=$_SESSION['usuEst'];
		$session=$_SESSION['sessionId'];				
		$itemSession=$_SESSION['itemSession'];	
		$codUsuario=$_SESSION['codUsuario'];																	
	}else{
		$session=false;
	}		
 if ($session==true){
error_reporting(E_ALL | E_STRICT);

require('upload.class.php');

$upload_handler = new UploadHandler();

$mi_fecha=$upload_handler->getDateBD();

header('Pragma: no-cache');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Content-Disposition: inline; filename="files.json"');
header('X-Content-Type-Options: nosniff');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: OPTIONS, HEAD, GET, POST, PUT, DELETE');
header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size');

switch ($_SERVER['REQUEST_METHOD']) {
    case 'OPTIONS':
        break;
    case 'HEAD':
    case 'GET':
        $upload_handler->get($codUsuario);
        break;
    case 'POST':
        if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') {
            $upload_handler->delete($codUsuario);
        } else {
            $upload_handler->post($codUsuario,$mi_fecha);
        }
        break;
    case 'DELETE':
        $upload_handler->delete($codUsuario);
        break;
    default:
        header('HTTP/1.1 405 Metodo no implementado');
}
}?>